package bTree.LeetCode;

import java.util.*;

public class 独一无二的出现次数 {
    public boolean uniqueOccurrences(int[] arr) {
        int length = arr.length;
        HashMap<Integer,Integer>hashMap=new HashMap<>();
        for (int i : arr) {
            if(!hashMap.containsKey(i)){
                hashMap.put(i,1);
            }else {
                hashMap.put(i,hashMap.get(i)+1);
            }
        }
        HashSet<Integer>hashSet=new HashSet<>();
        List<Map.Entry<Integer,Integer>>list=new ArrayList<>(hashMap.entrySet());
        for (Map.Entry entry : list) {
            Integer value = (Integer) entry.getValue();
            Integer key = (Integer) entry.getKey();
            if(!hashSet.contains(value)){
                hashSet.add(value);
            }else {
                return false;
            }
        }
        return true;
    }
}